package com.zzyl.config;

import com.zzyl.mapper.SysUserMapper;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * 自启动配置类
 */
@Component
public class ApplicationRunnerConfig implements ApplicationRunner {

    @Resource
    private SysUserMapper sysUserMapper;
    @Resource
    private RedisTemplate<String, Object> redisTemplate;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        String assignee0 = sysUserMapper.selectSysUserIdByPostName("养老顾问").toString();
        String assignee1 = sysUserMapper.selectSysUserIdByPostName("护理组主管").toString();
        String assignee2 = sysUserMapper.selectSysUserIdByPostName("副院长").toString();
        String assignee3 = sysUserMapper.selectSysUserIdByPostName("养老顾问").toString();
        String assignee4 = sysUserMapper.selectSysUserIdByPostName("法务专员").toString();

        HashMap<String, Object> map = new HashMap<>();
        map.put("assignee0",assignee0);
        map.put("assignee1",assignee1);
        map.put("assignee2",assignee2);
        map.put("assignee3",assignee3);
        map.put("assignee4",assignee4);

        redisTemplate.opsForHash().putAll("assignee",map);

        System.err.println("存入完成");


    }
}
